home *** CD-ROM | disk | FTP | other *** search
- <?php
-
- require_once('params.class.php');
-
- class TmcSql
- {
- private $db = null;
- private $showTrace = FALSE;
-
- function __construct($AshowTrace=FALSE, $Aupdating=FALSE)
- {
- if (!$Aupdating)
- {
- if (file_exists('empty.inc'))
- {
- echo("<html>");
- echo("<body>");
- echo("<b>La base de donnΘe doit Ωtre mise α jour</b><br />");
- echo("</body>");
- echo("</html>");
-
- die('');
- }
- }
-
- $this->showTrace = $AshowTrace;
-
- $sqliteerror = null;
- if (!($this->db = @sqlite_open($_SESSION["mc_params"]->getBdd(), 0666, $sqliteerror)))
- {
- die ($sqliteerror);
- }
- }
-
- function __destruct()
- {
- if (isset($this->db))
- sqlite_close($this->db);
- }
-
- function execSql($Astmt)
- {
- if ($this->showTrace)
- echo("<b>RequΩte: </b> ".nl2br($Astmt)."<br />");
- $result=@sqlite_query($this->db, $Astmt);
- $id_error=sqlite_last_error($this->db);
- if ($id_error)
- die("<b>".sqlite_error_string($id_error)."</b><br />");
- else
- {
- if ($this->showTrace)
- echo("<b>".sqlite_changes($this->db)." enregistrements modifΘ(s).</b><br />");
- }
- }
-
- function execSql_no_exception($Astmt)
- {
- if ($this->showTrace)
- echo("<b>RequΩte: </b> ".nl2br($Astmt)."<br />");
- $result=@sqlite_query($this->db, $Astmt);
- $id_error=sqlite_last_error($this->db);
- if ($id_error)
- {
- if ($this->showTrace)
- echo("<b>".sqlite_error_string($id_error)."</b><br />");
- }
- else
- {
- if ($this->showTrace)
- echo("<b>".sqlite_changes($this->db)." enregistrements modifΘ(s).</b><br />");
- }
- }
-
- function openSql($Astmt)
- {
- if ($this->showTrace)
- echo("<b>RequΩte: </b> ".nl2br($Astmt)."<br />");
- $result=@sqlite_query($this->db, $Astmt);
- $id_error=sqlite_last_error($this->db);
- if ($id_error)
- die("<b>".sqlite_error_string($id_error)."</b><br />");
-
- $rows = array();
- while ($r = sqlite_fetch_array($result))
- {
- $rows[] = $r;
- }
- return $rows;
-
- }
-
- }
-
- ?>